In [1]:
from pathlib import Path
from ipyniivue import download_dataset
# GitHub API URL for the base folder
BASE_API_URL = "https://niivue.com/demos/images/"
DATA_FOLDER = Path("images")
# Download data for example
download_dataset(
BASE_API_URL,
DATA_FOLDER,
files=[
"BrainMesh_ICBM152.lh.motor.mz3",
"BrainMesh_ICBM152.lh.mz3",
"CIT168.mz3",
],
)
BrainMesh_ICBM152.lh.motor.mz3 already exists. BrainMesh_ICBM152.lh.mz3 already exists. CIT168.mz3 already exists. Dataset downloaded successfully to images.
In [2]:
from ipyniivue import NiiVue
# GitHub API URL for the base folder
BASE_API_URL = "https://niivue.com/demos/images/"
nv = NiiVue(
show_3d_crosshair=True, back_color=(1, 1, 1, 1), mesh_xray=0.3, is_colorbar=True
)
mesh_layer = {
"path": DATA_FOLDER / "BrainMesh_ICBM152.lh.motor.mz3",
"cal_min": 0.5,
"cal_max": 5.5,
"use_negative_cmap": True,
"opacity": 0.7,
}
nv.load_meshes(
[
{
"path": DATA_FOLDER / "BrainMesh_ICBM152.lh.mz3",
"rgba255": [255, 255, 255, 255],
"layers": [mesh_layer],
},
{"path": DATA_FOLDER / "CIT168.mz3", "rgba255": [0, 0, 255, 255]},
]
)
@nv.on_mesh_loaded
def on_start(mesh):
"""Change mesh properties."""
nv.meshes[0].rgba255 = [0, 200, 200, 200]
nv.meshes[0].layers[0].opacity = 0.2
nv.set_mesh_layer_property(nv.meshes[0].id, 0, "opacity", 0.8)
nv
Out[2]: